<template>
  <div>
    <!--  顶部栏  -->
    <div class="header">
      <div class="right">
        <!-- <img class="avatar" src="../assets/avater.png">
        <div class="name">
          {{adminName}}
        </div> -->
        <img class="exist" src="@/assets/exist.png" @click="exit()">
      </div>
    </div>
    <!--  侧边栏  -->
    <div class="left-tab">
      <div class="tab-header">
        <img src="@/assets/logo.png">
        <h1>机关办公全场景</h1>
      </div>
      <div class="tab-list">
        <el-menu
      class="el-menu-vertical-demo"
      default-active="1"
      >
      <router-link to="/government/document" v-if="menuIds.includes(20)">
      <el-menu-item index="1">
        <span slot="title">错别字检索</span>
      </el-menu-item>
      </router-link>
      <el-submenu index="2">
        <template slot="title">
          <span>文档格式化</span>
        </template>
        <router-link to="/government/evidence" v-if="menuIds.includes(21)">
        <el-menu-item index="2-1">
          <span slot="title">取证单格式化</span>
        </el-menu-item>
        </router-link>
        <router-link to="/government/workpaper" v-if="menuIds.includes(22)">
        <el-menu-item index="2-2" >
          <span slot="title">审计底稿</span>
        </el-menu-item>
        </router-link>
        <router-link to="/government/auditReport" v-if="menuIds.includes(23)">
        <el-menu-item index="2-3">
          <span slot="title">审计报告</span>
        </el-menu-item>
        </router-link>
        <router-link to="/government/solicitingOpinions" v-if="menuIds.includes(24)">
        <el-menu-item index="2-4">
          <span slot="title">征求意见稿</span>
        </el-menu-item>
        </router-link>
      </el-submenu>
      <router-link to="/government/documentDesensitization" v-if="menuIds.includes(26)">
      <el-menu-item index="3">
        <span slot="title">文档脱敏</span>
      </el-menu-item>
      </router-link>
      <router-link to="/government/fileLocalFormat">
      <el-menu-item index="4">
        <span slot="title">文件本地格式化</span>
      </el-menu-item>
      </router-link>
    </el-menu>
      </div>
    </div>

    <!--  主体内容  -->
    <div class="main">
      <div class="block" ></div>
      <div class="main-content">
        <router-view></router-view>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'governmentWork',  
  data(){
    return{
      menuIds:[],
    }
  },
  computed: {
    // adminName(){
    //   return JSON.parse(localStorage.getItem('userInfo')).name;
    // },
    // adminType(){
    //   let user = JSON.parse(localStorage.getItem('userInfo')).name;
    //   return user === '测试账号1'?'测试账号':'普通用户'
    // },
  },
  methods:{
    getMenu(){
      console.log(120,localStorage.getItem("projectId"));
      let projectId=localStorage.getItem("projectId");
      this.$axios.get('/api/services/hzsfjtai/menu/getTreeDataByProjectId?projectId='+projectId, {}).then(res => {
            if (res.data.code === 200) {
              this.menuIds=res.data.data.map(pro => pro.id)
              console.log(89,this.menuIds);
               
            } else {
              this.$message(res.data.msg)
            }
          }).catch(err => {
            this.$message.error(err)
          })
    },
    exit(){
      this.$router.push({ path: '/dashboard' })
    },
  },
  mounted() {
    this.getMenu();
  }
}
</script>
<style scoped lang="less" >
  /* 顶部栏*/
  .header{
    z-index: 999;
    width: 100%;
    position: fixed;
    top: 0;
    display: flex;
    justify-content: flex-end;
    height: 64px;
    background-color: #fff;
    padding: 0 30px;
    border-bottom: solid 1px rgba(231, 231, 231, 1);
    .right{
      display: flex;
      height: 64px;
      align-items: center;
      .avatar{
        height: 35px;
        width: 35px;
      }
      .name{
        font-size: 16px;
        color: rgba(0, 0, 0, 1);
        margin-left: 10px;
      }
      .adminType{
        border-radius: 2px;
        background-color: rgba(0, 82, 217, 0.08);
        font-size: 14px;
        color: rgba(0, 82, 217, 1);
        padding: 4px 6px;
        margin-left: 10px;
      }
      .exist{
        height: 35px;
        width: 35px;
        padding: 8px;
        cursor: pointer;
        margin-left: 6px;
      }
    }
  }

  /*侧边栏*/
  .left-tab{
    position: fixed;
    top: 0;
    width: 188px;
    left: 0;
    z-index: 999;
    height: 100vh;
    background-color: #fff;
    .tab-header{
      width: 240px;
      height: 64px;
      display: flex;
      align-items: center;
      padding-left: 20px;
      border-bottom: solid 1px rgba(231, 231, 231, 1);
      img{
        height: 35px;
        width: 35px;
      }
      h1{
        font-size: 18px;
        margin-left: 10px;
      }
    }
    .tab-list{
      margin: 15px 10px;
      .tab-item{
        display: flex;
        height: 45px;
        justify-content: center;
        align-items: center;
        //background-color: #2468F2;
        border-radius: 5px;
        margin-bottom: 10px;
        transition: all .2s;
        i{
          font-size: 25px;
          color: rgba(233, 232, 237, 1);
        }
        .title{
          font-size: 14px;
          color: rgba(0, 0, 0, 0.6);
          margin-left: 12px;
        }
        &:hover{
          background-color: rgba(83, 86, 90, 0.05);
        }
      }
      .active{
        background-color: rgba(83, 86, 90, 0.05);
        i{
          color: rgba(57, 145, 238, 1);
        }
        .title{
          color: rgba(57, 145, 238, 1);
        }
      }
    }

  }

  /*主体*/
  .main{
    display: flex;
    width: 100%;
    //padding-top: 64px;
    .block{
      width: 188px;
      height: 100vh;
     
    }
    .main-content{
      overflow: hidden;
      flex: 1;
      margin: 72px 15px 15px 15px;
      background-color: #fff;
       z-index: 0;
    }
  }
  /deep/ .el-submenu .el-menu-item{
    min-width: 100px;
  }
  /deep/.el-menu{
    border-right: 0;
  }
</style>
<style  lang="less">
  .content{
    display:flex;
    padding:20px;
    .left-box{
      flex:0 0 200px;
      margin-right:30px;
    }
    .right-box{
      flex:1;
      border-left:1px solid #f2f3f5;
      padding-left :20px;
    }
  }
</style>

